const mongoose = require('mongoose');
const db = require('./db');
const _ = require('lodash');
const baseDao = require('./baseDao');
const Schema = mongoose.Schema;

const messageSchema = new Schema({
	title: { type: String },
    body: { type: String }, 
    userId: { type:String},
    createTime:{type:Date,default:Date.now},
    read:{type:Boolean}
},
{
	collection : 'message'
});

const Message = db.model('message', messageSchema);

const messageDao = Object.assign({

    model: Message,

    saveBatch: function(docs,callback){
        Message.create(docs,callback);
    }

}, baseDao);

module.exports = messageDao;